package br.mestrado.unb.bs.model.sensor;

import br.mestrado.unb.bs.model.constant.DataPackageConstant;

public class CommandPayload extends Payload{

	private Byte command 		= 0;
	private Byte sensorCategory	= 0;
	private Byte sensorId 		= 0;
	private Byte newValue 		= 0;

	public CommandPayload(Byte command) {
		super();
		this.command = command;
	}
	
	public CommandPayload(Byte command, Byte sensorCategory, Byte sensorId, Byte newValue){
		this.command 		= command;
		this.sensorCategory = sensorCategory;
		this.sensorId		= sensorId;
		this.newValue		= (Byte) newValue;
	}
	
	public byte[] toByteStream() {
		byte[] stream = new byte[DataPackageConstant.command_payload_size];
		stream[DataPackageConstant.i_command_value] 			= command;
		stream[DataPackageConstant.i_command_sensor_category] 	= sensorCategory;
		stream[DataPackageConstant.i_command_sensor_id] 		= sensorId;
		stream[DataPackageConstant.i_command_new_value] 		= newValue;
		return stream;
	}

	@Override
	public byte getSize() {
		return DataPackageConstant.command_payload_size;
	}

	@Override
	public byte getCategory() {
		return DataPackageConstant.command_category;
	}

	public final Byte getCommand() {
		return command;
	}

	public final void setCommand(Byte command) {
		this.command = command;
	}

	public final Byte getSensorCategory() {
		return sensorCategory;
	}

	public final void setSensorCategory(Byte sensorCategory) {
		this.sensorCategory = sensorCategory;
	}

	public final Byte getSensorId() {
		return sensorId;
	}

	public final void setSensorId(Byte sensorId) {
		this.sensorId = sensorId;
	}

	public final Byte getNewValue() {
		return newValue;
	}

	public final void setNewValue(Byte newValue) {
		this.newValue = newValue;
	}
	
}
